<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //1、let声明的变量是块级作用域、而var声明变量是函数作用域，但在if、for中声明的变量是全局作用域 


        //而var声明变量是函数作用域
        function demo(){
            var usr = '悟空';
            console.log(usr,111);
        }

       // demo();
       // console.log(usr,22);  //usr is not defined


       //在if、for中声明的变量是全局作用域

       for(var i =0;i<10;i++){
         // console.log(i,333);
       }

     //  console.log(i,444);


        if(1){
            var tel = 110;
            //let声明的变量是块级作用域
            let email = 'lisi@qq.com';  
            console.log(tel,email,'tel,email');
        }

       // console.log(tel,email,'tel,email  888');  //email is not defined


       if(3){
          let age = 20;
          if(6){
            console.log(age,'age');  //20
            let goods = '小为手机'
            
          }

          //console.log(goods,'goods');  //goods is not defined
       }


       for(var s = 0;s<10;s++){
           var s = 10;
           console.log(s,'s');
       }

       for(let t = 0;t<10;t++){
           let t = 10;
          console.log(t,'t');
       }

    </script>
</head>
<body>
    
</body>
</html>